//1-引入插件
import Vue from "vue";
import VueRouter from "vue-router";
import routes from "./routes";
//2-注册插件
Vue.use(VueRouter);
//创建路由实例对象
const router = new VueRouter({
  mode: "history",
  routes,
});

const originPush = VueRouter.prototype.push
const originReplace = VueRouter.prototype.replace

VueRouter.prototype.push = function (location, okCallback, errCallback) {
  if (okCallback && errCallback) {
    return originPush.call(this, location, okCallback, errCallback)
  } else {
    originPush.call(this, location).catch(() => {})
  }
}

VueRouter.prototype.replace = function (location, okCallback, errCallback) {
  if (okCallback && errCallback) {
    return originReplace.call(this, location, okCallback, errCallback)
  } else {
    originReplace.call(this, location).catch(() => {})
  }
}
export default router;
